package com.ruoyi.goods.service.impl;

import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.goods.domain.BmGoods;
import com.ruoyi.goods.mapper.SellerBrandMapper;
import com.ruoyi.goods.service.SellerBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author 白大帅
 * @Date: 2023/08/11/ 19:06
 */
@Service
public class SellerBrandServiceImpl implements SellerBrandService {
    @Autowired
    private SellerBrandMapper sellerBrandMapper;

    @Resource
    private RedisService redisService;

    @Override
    public List<BmGoods> getGoods(BmGoods bmGoods) {

        return sellerBrandMapper.getGoods(bmGoods);
    }

    @Override
    public List<Map<String, Object>> getList(Map<String, Object> map) {
        return sellerBrandMapper.getList(map);
    }

    @Override
    public List<BmGoods> recommondGoods(BmGoods bmGoods) {
        String key ="bai:recommondGoods";
        List<BmGoods> list = redisService.getCacheObject(key);
        if (list==null||list.size()==0){
            list=sellerBrandMapper.recommondGoods(bmGoods);
            redisService.setCacheObject(key,list);
        }
        return list;
    }

    @Override
    public List<Map<String,Object>> oftenBuy() {
//        String key = "bai:oftenBuy";
//        List<Map<String, Object>> list = redisService.getCacheObject(key);
//        if (list==null || list.size()==0){
//            list=sellerBrandMapper.oftenBuy();
//            redisService.setCacheObject(key,list);
//        }
//        return list;
        return sellerBrandMapper.oftenBuy();
    }
}
